<?php
defined('IN_IXDCW') or exit('Access Denied');
include tpl('header');
show_menu($menus);
?>
<form method="post" action="?" id="runcode_form" target="_blank">
    <input type="hidden" name="moduleid" value="<?php echo $moduleid;?>"/>
    <input type="hidden" name="file" value="<?php echo $file;?>"/>
    <input type="hidden" name="action" value="runcode"/>
    <input type="hidden" name="codes" id="codes" value=""/>
</form>
<form method="post" action="?" id="dform" onsubmit="return check();">
    <input type="hidden" name="moduleid" value="<?php echo $moduleid;?>"/>
    <input type="hidden" name="file" value="<?php echo $file;?>"/>
    <input type="hidden" name="action" value="<?php echo $action;?>"/>
    <input type="hidden" name="forward" value="<?php echo $forward;?>"/>
    <input type="hidden" name="pid" value="<?php echo $p['pid'];?>"/>
	<input type="hidden" name="autoSubnationPrice" value="<?php echo $p['subnation_price'];?>"/>
    <div class="tt">添加广告</div>
    <table cellpadding="2" cellspacing="1" class="tb">
         <tr>
            <td class="tl"><span class="f_hid">*</span> 广告位id</td>
            <td class="f_b">&nbsp;<?php echo $p['pid'];?></td>
        </tr>
        <tr>
            <td class="tl"><span class="f_hid">*</span> 广告位</td>
            <td class="f_b">&nbsp;<?php echo $p['name'];?></td>
        </tr>
        <tr>
            <td class="tl"><span class="f_hid">*</span> 广告类型</td>
            <td class="f_gray">&nbsp;<?php echo $TYPE[$p['typeid']];?></td>
        </tr>
        <tr>
            <td class="tl">广告位全国站默认价格</span></td>
            <td>&nbsp;<?php echo $p['nation_price'];?></td>
        </tr>
        <tr>
            <td class="tl">广告位地区站默认价格</td>
            <td>&nbsp;<?php echo $p['subnation_price'];?></td>
        </tr>
    </table>
    <ul class="ad-price-list clear">
        <?php foreach($subnationPrice as $areaid => $price){ ?>
		<li>
        	<label>&nbsp;<?php echo $AREA[$areaid]['areaname'];?>: </label>
            <input name="subnationPrice[<?php echo $areaid;?>]" type="text" size="10" value="<?php echo $price;?>"/>
        </li>
        <?php } ?>
    </ul>
    <div class="sbt"><input type="submit" name="submit" value=" 确 定 " class="btn"/>&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value=" 返 回 " class="btn" onclick="history.back(-1);"/></div>
</form>
<?php load('clear.js'); ?>
<script type="text/javascript">
    function check() {
        var l;
        var f;
        var t = <?php echo $p['typeid'];?>;
        f = 'title';
        l = Dd(f).value.length;
        if (l < 1) {
            Dmsg('请填写广告名称', f);
            return false;
        }
        if (Dd('adfromtime').value.length != 10 || Dd('adtotime').value.length != 10) {
            Dmsg('请填写投放时段', 'time');
            return false;
        }
        if (t == 1 || t == 7) {
            f = 'code';
            l = Dd(f).value.length;
            if (l < 5) {
                Dmsg('请填写广告代码', f);
                return false;
            }
        } else if (t == 2) {
            f = 'text_name';
            l = Dd(f).value.length;
            if (l < 2) {
                Dmsg('请填写链接文字', f);
                return false;
            }
            f = 'text_url';
            l = Dd(f).value.length;
            if (l < 12) {
                Dmsg('请填写链接地址', f);
                return false;
            }
        } else if (t == 3 || t == 5) {
            f = 'thumb';
            l = Dd(f).value.length;
            if (l < 2) {
                Dmsg('请填写图片地址', f);
                return false;
            }
            if (t == 5 && ext(Dd(f).value) != 'jpg') {
                Dmsg('仅支持JPG格式图片', f);
                return false;
            }
        } else if (t == 4) {
            f = 'flash';
            l = Dd(f).value.length;
            if (l < 5) {
                Dmsg('请填写Flash地址', f);
                return false;
            }
        } else if (t == 6) {
            f = 'key_id';
            l = Dd(f).value.length;
            if (l < 1) {
                Dmsg('请填写信息ID', f);
                return false;
            }
        }
        return true;
    }
    function runcode() {
        if (Dd('code').value.length < 3) {
            Dmsg('请填写代码', 'code');
            return false;
        }
        Dd('codes').value = Dd('code').value;
        Dd('runcode_form').submit();
    }
</script>
<script type="text/javascript">Menuon(2);</script>
<?php include tpl('footer'); ?>